package io.github.qifan777.server.task.entity;

import io.github.qifan777.server.address.entity.dto.AddressView;
import io.github.qifan777.server.dict.model.DictConstants;
import io.github.qifan777.server.infrastructure.jimmer.BaseEntity;
import io.github.qifan777.server.order.entity.BaseOrder;
import io.github.qifan777.server.user.root.entity.User;
import io.qifan.infrastructure.generator.core.*;
import jakarta.annotation.Nullable;
import org.babyfish.jimmer.sql.Entity;
import org.babyfish.jimmer.sql.ManyToOne;
import org.babyfish.jimmer.sql.Serialized;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 任务订单
 */
@GenEntity
@Entity
public interface TaskOrder extends BaseEntity {

    /**
     * 任务类型
     */
    @GenDictField(label = "任务类型", dictEnName = DictConstants.TASK_TYPE, order = 1)
    DictConstants.TaskType type();

    @GenDictField(label = "商品类型", dictEnName = DictConstants.GOODS_TYPE, order = 2)
    DictConstants.GoodsType goodsType();

    /**
     * 重量
     */
    @GenNumberField(label = "重量", order = 2)
    BigDecimal weight();

    /**
     * 状态
     */
    @GenDictField(label = "状态", dictEnName = DictConstants.TASK_ORDER_STATUS, order = 4)
    DictConstants.TaskOrderStatus status();

    /**
     * 目的地址
     */

    @Serialized
    AddressView targetAddress();

    /**
     * 出发地址
     */
    @Serialized
    AddressView sourceAddress();

    /**
     * 开始时间
     */
    @GenDateTimeField(label = "开始时间", order = 5)
    LocalDateTime startTime();

    /**
     * 结束时间
     */
    @GenDateTimeField(label = "结束时间", order = 6)
    LocalDateTime endTime();

    /**
     * 接单人
     */
    @GenAssociationField(label = "接单人", prop = "deliverId")
    @Nullable
    @ManyToOne
    User deliver();

    @ManyToOne
    BaseOrder baseOrder();
}

